package org.bmi.gwt.examples.array.shared;

import org.bmi.gwt.mi.shared.MiObject;

public class ObjArrayObject implements MiObject
{
	private Component[] intArray;
	private PrinterObject printer;

	public ObjArrayObject(Component[] str, PrinterObject printer)
	{
		this.intArray = str;
		this.printer = printer;
	}

	public Component[][] createArray()
	{
		Component[][] array = new Component[this.intArray.length][this.intArray.length];

		for (int i = 0; i < this.intArray.length; i++)
			for (int j = 0; j < this.intArray.length; j++)
				array[i][j] = this.intArray[i];

		return array;
	}

	public void print1Array(Component[] arr)
	{
		this.printer.printLn("1 dimensional object array test...");

		for (int i = 0; i < arr.length; i++)
			this.printer.print(" " + arr[i].getStr());

		this.printer.printLn("");
	}

	public void print2Array(Component[][] arr)
	{
		this.printer.printLn("2 dimensional object array test...");

		for (int i = 0; i < arr.length; i++)
		{
			for (int j = 0; j < arr[i].length; j++)
				this.printer.print(" " + arr[i][j].getStr());

			this.printer.printLn("");
		}
	}
}
